library(dplyr)
library(Seurat)
library(patchwork)
library(ggplot2)
library(sctransform)

# Reference: https://satijalab.org/seurat/articles/sctransform_vignette.html

ciprec25_data = read.csv(file = 'data_for_sctransform.csv', row.names = 1)
ciprec25 <- CreateSeuratObject(counts = ciprec25_data, project = "POS", min.cells = 3, min.features = 1)
ciprec25 <- SCTransform(ciprec25, vst.flavor = 'v2', new.assay.name = "SCT", return.only.var.genes = TRUE, verbose = FALSE)

sctnorm_scaledata = ciprec25[["SCT"]]@scale.data
sctnorm_counts = ciprec25[["SCT"]]@counts
write.csv(sctnorm_scaledata, "sct_wcre_scaleddata.csv")
write.csv(sctnorm_counts, "sct_wcre_corrected_counts.csv")

